package edu.dayu.controller;

import com.github.pagehelper.PageInfo;
import edu.dayu.pojo.ClubPerson;
import edu.dayu.service.ClubPersonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@CrossOrigin
@RequestMapping("/admin")
public class ClubPersonController {
    @Autowired
    private ClubPersonService clubPersonService;

    @PostMapping("/clubPersonList")
    public PageInfo<ClubPerson> clubPersonList(ClubPerson clubPerson){
        return clubPersonService.clubPersonList(clubPerson);
    }

    @PostMapping("/clubPersonInsert")
    public void clubPersonInsert(ClubPerson clubPerson){
        clubPersonService.clubPersonInsert(clubPerson);
    }

    @PostMapping("/clubPersonById")
    public ClubPerson clubPersonById(ClubPerson clubPerson){
        PageInfo<ClubPerson> personPageInfo = clubPersonService.clubPersonList(clubPerson);
        List<ClubPerson> list = personPageInfo.getList();
        ClubPerson clubPerson1 = new ClubPerson();
        for (ClubPerson person : list) {
            clubPerson1 = person;
        }
        return clubPerson1;
    }

    @PostMapping("/clubPersonUpdate")
    public void clubPersonUpdate(ClubPerson clubPerson){
        clubPersonService.clubPersonUpdate(clubPerson);
    }

    @PostMapping("/clubPersonDelete")
    public void clubPersonDelete(ClubPerson clubPerson){
        clubPersonService.clubPersonDelete(clubPerson);
    }
}
